package com.code2roc.fastboot.workflow.config;

import com.code2roc.fastboot.framework.database.JDBCDTO;
import com.code2roc.miniflow.app.IMiniFlowDataBaseBridge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@Service
public class WorkFlowDataBaseBridge implements IMiniFlowDataBaseBridge {
    @Autowired
    private JDBCDTO jdbcdto;

    @Override
    public List<LinkedHashMap<String, Object>> findList(String sqlText, Map<String, Object> paramMap) {
        return jdbcdto.findListByParam(sqlText, paramMap);
    }

    @Override
    public List<LinkedHashMap<String, Object>> findPageList(String sqlText, int pageIndex, int pageSize, Map<String, Object> paramMap) {
        sqlText += " limit " + (pageIndex - 1) * pageSize + "," + pageSize + ";";
        return jdbcdto.findListByParam(sqlText, paramMap);
    }

    @Override
    public int executeSQL(String sqlText, Map<String, Object> paramMap) {
        return jdbcdto.executeSQL(sqlText, paramMap);
    }

    @Override
    public Object executeScar(String sqlText, Map<String, Object> paramMap) {
        return jdbcdto.executeScar(sqlText, paramMap);
    }
}
